import os.path
import time
import unittest
from HTMLTestRunner import HTMLTestRunner
from autoframe.case import browse_products_case, register_case, login_case

loader = unittest.defaultTestLoader.loadTestsFromModule(browse_products_case)
loader1 = unittest.defaultTestLoader.loadTestsFromModule(register_case)
loader2 = unittest.defaultTestLoader.loadTestsFromModule(login_case)

report = os.path.abspath('report')
filename = time.strftime('%Y-%m-%d-%H：%M：%S') + '浏览注册登录-demo.html'
filepath = os.path.join(report, filename)

# 写入文件，执行测试用例，生成测试报告
with open(filepath, 'wb') as f:
    runner = HTMLTestRunner(
        title='测试报告',
        description='浏览注册登录的测试用例',
        tester='郑全友',
        stream=f,
        verbosity=2
    )
    runner.run(loader)
    runner.run(loader1)
    runner.run(loader2)
